{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "paths = ['../data/MICCAI_BraTS_2019_Data_Validation',\n",
    "        '../data/MICCAI_BraTS_2018_Data_Testing_VEvgeniy',\n",
    "        '../data/2018_deca_cropped']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "mods = {\n",
    "    '_t1.nii.gz' : 't1.nii.gz',\n",
    "    '_t1ce.nii.gz' : 't1c.nii.gz',\n",
    "    '_t2.nii.gz' : 't2.nii.gz',\n",
    "    '_flair.nii.gz' : 'fla.nii.gz',\n",
    "    #'_flair.nii.gz' : 'flair.nii.gz',\n",
    "}\n",
    "\n",
    "for p in paths:\n",
    "    files = [f for f in os.listdir(p) if os.path.isdir(os.path.join(p,f))]\n",
    "    \n",
    "    for f in files:\n",
    "        os.chdir(os.path.join(p,f))\n",
    "        #print(os.getcwd())\n",
    "        #print(os.listdir(os.getcwd()))\n",
    "        for k,v in mods.items():\n",
    "            src = f+k#os.path.join(p,f,f+k)\n",
    "            dst = os.path.join(p,f,v)\n",
    "            if os.path.isfile(dst):\n",
    "                os.remove(dst)\n",
    "            \n",
    "            os.symlink(src, dst)\n",
    "        #print(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}